package sysu.el.array.algors;

import java.util.Collections;
import java.util.List;

public class Sig{

	public static String mkString(int[][] w, 
			String delimeter1, String delimeter2){
		return new String(mkStrBuf(w.length, w, delimeter1, delimeter2));
	}
	
	
	public static String mkString(int num1, int[][] w, 
			String delimeter1, String delimeter2){
		return new String(mkStrBuf(num1, w, delimeter1, delimeter2));
	}
	
	public static StringBuffer mkStrBuf(int num1, int[][] w, 
			String delimeter1, String delimeter2){
		StringBuffer sb = new StringBuffer();
		for (int i=0; i<num1; i++){
			int num2 = w[i].length;
			for (int j=0; j<num2-1; j++){
				sb.append(w[i][j]);
				sb.append(delimeter2);
			}
			sb.append(w[i][num2-1]);
			sb.append(delimeter1);
		}
		return sb;
	}
	
	public static String mkString(int num1, int num2, int[][] w, 
			String delimeter1, String delimeter2){
		return new String(mkStrBuf(num1, num2, w, delimeter1, delimeter2));
	}
	
	public static StringBuffer mkStrBuf(int num1, int num2, int[][] w, 
			String delimeter1, String delimeter2){
		StringBuffer sb = new StringBuffer();
		for (int i=0; i<num1; i++){
			for (int j=0; j<num2-1; j++){
				sb.append(w[i][j]);
				sb.append(delimeter2);
			}
			sb.append(w[i][num2-1]);
			sb.append(delimeter1);
		}
		return sb;
	}
	
	
	/*
	 * Int
	 */
	public static StringBuffer mkStrBuf(int num, int[] str, String delimeter){
		StringBuffer sb = new StringBuffer();
		for (int i=0; i<num-1; i++){
			sb.append(str[i]);
			sb.append(delimeter);
		}
		sb.append(str[num-1]);
		return sb;
	}	
	
	public static String mkString(int num, int[] str, String delimeter){
		return new String(Sig.mkStrBuf(num, str, delimeter));
	}
	
	public static String mkString(int[] str, String delimeter){
		return new String(Sig.mkStrBuf(str.length, str, delimeter));
	}
	
	/*
	 * Double
	 */
	public static StringBuffer mkStrBuf(int num, double[] str, String delimeter){
		StringBuffer sb = new StringBuffer();
		for (int i=0; i<num-1; i++){
			sb.append(str[i]);
			sb.append(delimeter);
		}
		sb.append(str[num-1]);
		return sb;
	}
	
	public static String mkString(int num, double[] str, String delimeter){
		return new String(Sig.mkStrBuf(num, str, delimeter));
	}
	
	public static String mkString(double[] str, String delimeter){
		return new String(Sig.mkStrBuf(str.length, str, delimeter));
	}
	/*
	 * Float
	 */
	public static StringBuffer mkStrBuf(int num, float[] str, String delimeter){
		StringBuffer sb = new StringBuffer();
		for (int i=0; i<num-1; i++){
			sb.append(str[i]);
			sb.append(delimeter);
		}
		sb.append(str[num-1]);
		return sb;
	}
	
	public static String mkString(int num, float[] str, String delimeter){
		return new String(Sig.mkStrBuf(num, str, delimeter));
	}
	
	public static String mkString(float[] str, String delimeter){
		return new String(Sig.mkStrBuf(str.length, str, delimeter));
	}
	
	/*
	 * String
	 */
	public static StringBuffer mkStrBuf(int num, String[] str, String delimeter){
		StringBuffer sb = new StringBuffer();
		for (int i=0; i<num-1; i++){
			sb.append(str[i]);
			sb.append(delimeter);
		}
		sb.append(str[num-1]);
		return sb;
	}
	
	public static StringBuffer mkStrBuf(int num, StringBuffer[] str_buf, String delimeter){
		StringBuffer sb = new StringBuffer();
		for (int i=0; i<num-1; i++){
			sb.append(str_buf[i]);
			sb.append(delimeter);
		}
		sb.append(str_buf[num-1]);
		return sb;
	}
	
	public static String mkString(int num, StringBuffer[] str_buf, String delimeter){
		return new String(Sig.mkStrBuf(num, str_buf, delimeter));
	}
	
	public static String mkString(int num, String[] str, String delimeter){
		return new String(Sig.mkStrBuf(num, str, delimeter));
	}
	
	public static StringBuffer mkStrBuf(StringBuffer[] str_buf, String delimeter){
		return Sig.mkStrBuf(str_buf, delimeter);
	}
	
	public static StringBuffer mkStrBuf(String[] str, String delimeter){
		return Sig.mkStrBuf(str.length, str, delimeter);
	}
	
	public static String mkString(String[] str, String delimeter){
		return Sig.mkString(str.length, str, delimeter);
	}
	
	public static String mkString(StringBuffer[] str_buf, String delimeter){
		return Sig.mkString(str_buf.length, str_buf, delimeter);
	}
}
